﻿using HuabanAutoPost.Helper;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HuabanAutoPost
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
    Login();
        }

        private void Login()
        {
            WebHelper.GetHtml("http://huaban.com/");
            NameValueCollection loginData = new NameValueCollection();
            loginData.Add("email", File.ReadAllText(".\\user.txt"));
            loginData.Add("password", File.ReadAllText(".\\pass.txt"));
            WebHelper.PostTohuaban(loginData, "https://huaban.com/auth/?dialog=1");
        }

        private void button1_Click(object sender, EventArgs e)
        {

            HuabanHelper.Publish.GetTicket(textBox2.Text, textBox1.Text, textBox1.Text, "http://pic.moetutu.com/41354");
        }





        private void button2_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start(".\\");
        }

        private void button3_Click(object sender, EventArgs e)
        {

            NameValueCollection loginData = new NameValueCollection();

            loginData.Add("title", textBox2.Text);
            loginData.Add("creation", "false");



            WebHelper.PostTohuaban(loginData, "https://huaban.com/boards/");
        }

        private void button4_Click(object sender, EventArgs e)
        {
            CookieAwareWebClient catup = new CookieAwareWebClient();
            catup.Headers.Add("Referer", "http: //sinaimg.cx/");
            catup.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0");
            catup.Headers.Add("Referer", "http: //sinaimg.cx/");

            byte[] responseArray = catup.UploadFile("http://61.171.57.31:672/v1/upload", ".\\12.jpg");
            // Decode and display the response.
            Console.WriteLine("\nResponse received was :\n{0}", Encoding.UTF8.GetString(responseArray));
        }

        private void button5_Click(object sender, EventArgs e)
        {
            Moetutu.Scanner.Start(Convert.ToInt32(textBox3.Text), Convert.ToInt32(textBox4.Text));
        }
    }
}
